import request from 'umi-request';

export async function employeesList(params,value = {}) {
  return request('/hr-ssc/api/api-admin/hrEvent/list', {
    method: 'post',
    data: {
      pageNum: params.current,
      pageSize: params.pageSize,
      employeeOid:params.employeeOid,
      isSendContract:parseInt(value),
      isEntryStatus:1,
      name:params.name,
      orgname:params.orgname,
      unitname:params.unitname,
      jobname:params.jobname
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function saveContractInfo(params = {}) {
  return request('/hr-ssc/api/api-admin/eSign/saveContractUrlInfo', {
    method: 'post',
    data: {
      oid: params.oid,
      representativeStart: params.contractStartTime,
      representativeEnd:params.contractEndTime,
      salary:params.salary,
      companyId:params.companyId,
      representativeLimit:params.laborContractYears,
      workAddress:params.work,
      contractAddress:params.contract,
      server:params.server,
      serverId:params.serverId,
      serverName:params.serverName,
      salaryDate:params.salaryDate,
      modelId:params.modelId,
    },
  }).then((res) => {
    return res;
  });
}

export async function getContractSubjectList() {
  return request('/hr-ssc/api/api-admin/eSign/getCompanyList', {
    method: 'post',
  }).then((res) => {
    return res.data;
  });
}

export async function getRelativeRecordsInfo(oid) {
  return request(`/hr-ssc/api/api-admin/newEmployees/getRelativeRecords/${oid}`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}

export async function getContractModelList() {
  return request('/hr-ssc/api/api-admin/eSign/getContractModelList', {
    method: 'post',
    data:{
      type:0
    },
    requestType: 'form'
  }).then((res) => {
    return res.data;
  });
}

export async function getEmployeeById(id) {
  return request(`/hr-ssc/api/api-admin/hrEvent/getEmployeeById/${id}`, {
    method: 'get',
  }).then((res) => {
    return res.data;
  });
}
